package com.zzy.jkb.util;

import com.zzy.jkb.entity.MailRequest;
import com.zzy.jkb.service.SendMailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName TaskSend
 * @Author ITOD011
 * @Description TODO
 * @Date 2023/2/22 10:39
 **/
@Slf4j
@Component
public class TaskSend {

    @Autowired
    SendMailService sendMailService;

    @Scheduled(cron = "0 15 06 28 * ?")
    public void sendEmail() {
        MailRequest mailRequest = new MailRequest();
        mailRequest.setSendTo("510307801@qq.com");
        mailRequest.setSubject("测试邮件");

        String html = "<html>\n" +
                "<body>\n" +
                "<p>请点击下方链接注册</p>\n" +
                "<a href=\"http://172.30.34.238:8000/jkb/user/save1\">点我注册</a>" +
                "</body>\n" +
                "</html>";
        mailRequest.setText(html);
        sendMailService.sendHtmlMail(mailRequest);
        log.info("定时任务发送邮件成功--------------------");


    }
}
